package thread;

import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

public class TimerTest {
	public static void main(String[] args) {
		test();
	}

	private static void test() {
		class Task extends TimerTask{
			Calendar c = Calendar.getInstance();
			@Override
			public void run() {
				System.out.printf("%tr%n", c);
				c.add(Calendar.SECOND, 1);
			}
		}
		Timer t = new Timer();
		t.schedule(new Task(),0, 1000);
	}
	
}
